package com.sx.micowell.module.homePage

import android.util.Log
import android.widget.TextView
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.mvvm.base.data.DataBindingConfig
import com.google.android.material.tabs.TabLayout
import com.gyf.immersionbar.ImmersionBar
import com.miloyu.modelnet.response.log
import com.sx.micowell.BR
import com.sx.micowell.R
import com.sx.micowell.databinding.FragTrainBinding
import com.sx.micowell.framework.app.MyFragment
import com.sx.micowell.framework.arouth.RoutePath
import com.sx.micowell.framework.model.TrainModel
import com.sx.micowell.framework.tools.getTextView
import com.sx.micowell.module.MainActivity
import kotlinx.android.synthetic.main.frag_train.*

/**
 * @Description 主页-训练
 * @Author 梁浩文
 * @Date 2021/7/27 9:15
 */
@Route(path = RoutePath.Train)
class TrainFragment : MyFragment<FragTrainBinding, MainActivity>() {

    lateinit var viewModel: TrainModel
    override fun initViewModel() {
        viewModel=getActivityScopeViewModel(TrainModel::class.java)
    }

    override fun getDataBindingConfig(): DataBindingConfig =
        DataBindingConfig(R.layout.frag_train, BR.viewModel, viewModel)
            .addBindingParam(BR.manager, childFragmentManager)
            .addBindingParam(BR.context, this)

    override fun initView() {
        ImmersionBar.with(this).titleBar(train_tab).statusBarDarkFont(true).init()
        viewModel.initFragment()

    }
    override fun initData() {
        train_tab.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
            override fun onTabSelected(tab: TabLayout.Tab) {
                val view = tab.customView
                if (null == view) {
                    tab.setCustomView(R.layout.view_tab_text)
                }
                val textView: TextView = tab.customView!!.findViewById(android.R.id.text1)
                textView.setTextAppearance(R.style.TabLayoutTextSize);
            }

            override fun onTabUnselected(tab: TabLayout.Tab) {
                val view = tab.customView
                if (null == view) {
                    tab.setCustomView(R.layout.view_tab_text)
                }
                val textView: TextView = tab.customView!!.findViewById(android.R.id.text1)
                textView.setTextAppearance(R.style.TabLayoutTextSize_default)
            }

            override fun onTabReselected(tab: TabLayout.Tab?) {
            }

        })
    }

}